// pages/home/active/index.js
import {
  getActivityOfflineListApi,
  getActivityListApi
} from '../../../https/activity.js'
import {
  BASE_URL
} from '../../../constant/index'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    BASE_URL,
    offlineList: [],
    list: [],
    limit: 100,
    page: 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getOfflineList()
    this.getList()
  },
  // 获取线下赛事数据
  async getOfflineList() {
    const getRes = await getActivityOfflineListApi({
      limit: 10,
      page: 1
    })
    console.log(getRes)
    if (getRes.code == 200) {
      this.setData({
        offlineList: getRes.data.list
      })
    }
  },
  // 获取全部赛事
  async getList() {
    const {
      limit,
      page
    } = this.data
    const getRes = await getActivityListApi({
      limit,
      page
    })
    if (getRes.code == 200) {
      this.setData({
        list: getRes.data.list
      })
    }
  },
  // 跳转赛事详情
  gotoGameDetail(e) {
    console.log(e)
    const docid = e.currentTarget.dataset.docid
    wx.navigateTo({
      url: '../gameDetail/index?docid=' + docid,
    })
  }

})